package _Banque._TUN;

import _Banque.*;
import _Exception.*;
import _Tests.Tests;

//
//IUT de Nice / Departement informatique / Module APO-C++
//Annee 2008_2009 - Package _Banque
//
//Classe CompteEpargne - Tests unitaires de la methode executer
//                      (Cas nominaux)
//
//Auteur : T.Tran Van Thoan - Q.Salmeron
//

public class T_CompteEpargne_N4_1 {
	
	public static void main (String args[]) throws IPException, BUException {
		
		Tests.Begin("_Banque.CompteEpargne", "1.5.0");
		
		Banque b = new Banque();

		String adresse_1= "Imm. Les Magnolias Bat. 2, 8 Bd Napoleon III - NICE (06000)";
		String adresse_2= "Villa Beau Sejour, 115 Av. de la Grande Armee - PARIS (75000)";
		Titulaire dupuy = new Titulaire("DUPUY", "Melanie", "1978/04/25", adresse_1);
		Titulaire durand = new Titulaire("Durand", "Paul", "1981/01/03",  adresse_2);
		//String titulaire_1= "DUPUY Melanie (1978/04/25) - Imm. Les Magnolias Bat. 2, 8 Bd Napoleon III - NICE (06000)";
		//String titulaire_2= "DURAND Paul (1981/01/03) - Villa Beau Sejour, 115 Av. de la Grande Armee - PARIS (75000)";
		
			Tests.Design("Controle du service executer", 3); {
				
				Tests.Case("Cas d'un seul compte / Retrait superieur ou egal a 200"); {
					CompteEpargne cpt = new CompteEpargne(b, dupuy, 0.05f);
					
					cpt.executer('V', "Guichet 322455", 1100f);
					
					Tests.Unit(1100.0f, cpt.getSoldeCompte());
					Tests.Unit(1, cpt.getNombreOperations());
					
					cpt.executer('R', "Facture 2009-39", 200);
					Tests.Unit(900.0f, cpt.getSoldeCompte());
					Tests.Unit(2, cpt.getNombreOperations());
				}
				
				Tests.Case("Cas d'un seul compte / Retraits superieurs a 200"); {
					CompteEpargne cpt = new CompteEpargne(b, dupuy, 0.05f);
					
					cpt.executer('V', "Guichet 322455", 200f);  
					 
		            Tests.Unit(200.0f,   cpt.getSoldeCompte());
		            Tests.Unit(1,        cpt.getNombreOperations());

		            cpt.executer('V', "Guichet 322455", 520f);  
				 
		            Tests.Unit(720.0f,   cpt.getSoldeCompte());
		            Tests.Unit(2,        cpt.getNombreOperations());

		            cpt.executer('R', "Facture 2009-29", 300f);  
				 
		            Tests.Unit(420.0f,   cpt.getSoldeCompte());
		            Tests.Unit(3,        cpt.getNombreOperations());

		            cpt.executer('R', "Facture 2009-30", 220f);   
				 
		            Tests.Unit(200.0f,   cpt.getSoldeCompte());
		            Tests.Unit(4,        cpt.getNombreOperations());
				}
				
				Tests.Case("Cas de plusieurs comptes"); {
					CompteEpargne cpt_1 = new CompteEpargne(b, dupuy, 0.05f);
					CompteEpargne cpt_2 = new CompteEpargne(b, durand, 0.03f);
					
					cpt_1.executer('V', "Guichet 322455",  200f);  
		            cpt_1.executer('V', "Guichet 322455",  320.5f);  
		            cpt_1.executer('R',   "Facture 2009-29", 400f);  
		            cpt_1.executer('V', "Guichet 322455",  100f);
				 
		            Tests.Unit(220.5f,     cpt_1.getSoldeCompte());
		            Tests.Unit(4,          cpt_1.getNombreOperations());

		            cpt_2.executer('V', "Guichet 760999", 350);  
				 
		            Tests.Unit(350.f,      cpt_2.getSoldeCompte());
		            Tests.Unit(1,          cpt_2.getNombreOperations());

		            cpt_2.executer('R', "Facture 2009-04", 300);

		            Tests.Unit(50.f,       cpt_2.getSoldeCompte());
		            Tests.Unit(2,          cpt_2.getNombreOperations());
				}
				
				Tests.Case("Cas de l'augmentation de la taille de l'historique"); {
					CompteEpargne cpt = new CompteEpargne(b, dupuy, 0.05f);
					
					// Premiere serie de 10 operations
		            //
		            cpt.executer('V', "Guichet 322455", 200f);  
		            cpt.executer('V', "Guichet 322455", 320.5f);  
		            cpt.executer('R',   "Facture 2009-29", 400f);  
		            cpt.executer('V', "Guichet 322455", 100f);
		            cpt.executer('R',   "Facture 2009-30", 20.5f);  
		            cpt.executer('V', "Guichet 322455", 100f);
		            cpt.executer('R',   "Facture 2009-31",100f);  
		            cpt.executer('V', "Guichet 322455", 100f);
		            cpt.executer('R',   "Facture 2009-32",100f);  
		            cpt.executer('V', "Guichet 322455", 100f);
					
		            Tests.Unit(298.236023f,  cpt.getSoldeCompte());
		            Tests.Unit(10,           cpt.getNombreOperations());
		            
		            // Seconde serie de 10 operations
		            //
		            cpt.executer('V', "Guichet 322455", 100f);
		            cpt.executer('V', "Guichet 322455", 100f);
		            cpt.executer('V', "Guichet 322455", 100f);
		            cpt.executer('V', "Guichet 322455", 100f);
		            cpt.executer('V', "Guichet 322455", 100f);
		            cpt.executer('V', "Guichet 322455", 100f);
		            cpt.executer('V', "Guichet 322455", 100f);
		            cpt.executer('V', "Guichet 322455", 100f);
		            cpt.executer('V', "Guichet 322455", 100f);
		            cpt.executer('V', "Guichet 322455", 100f); 

		            Tests.Unit(1298.236023f, cpt.getSoldeCompte());
		            Tests.Unit(20,           cpt.getNombreOperations());
				}
			}
		Tests.End();
	}
}
